﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="CompareThreadManager.cs" company="SmartPlan">
//   SmartPlan 2011
// </copyright>
// <summary>
//   Defines the CompareThreadManager type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace DbDiff.WinClient.Helper
{
    using Common.Comparer;
    using Common.Model;

    public class CompareThreadManager : ThreadManager 
    {
        #region Fields & properties
        public DatabaseCompare DatabaseCompare 
        {
            get 
            {
                return ((CompareWorkerThread)_workerThread).DatabaseCompare;
            }
        }
        #endregion Fields & properties

        #region Constructors
        public CompareThreadManager (FormThread formThread, CompareWorkerThread workerThread) 
            : base(formThread, workerThread)
        {
            workerThread.OnCompare += new CompareWorkerThread.OnCompareThreadEventHandler(OnCompare);
            workerThread.OnCompareStart += new CompareWorkerThread.OnCompareInfoThreadEventHandler(OnCompareStart);
            workerThread.OnCompareEnd += new CompareWorkerThread.OnCompareInfoThreadEventHandler(OnCompareEnd);
        }
        #endregion Constructors

        #region Event handlers 
        private void OnCompare(object sender, CompareEventArgs e) 
        {
            ((CompareFormThread)_formThread).SetCompareStatus(e.ObjectType, e.ObjectName);
        }
        private void OnCompareStart(object sender, CompareInfoEventArgs e) 
        {
            ((CompareFormThread)_formThread).StartCompare(e.Info);
        }
        private void OnCompareEnd(object sender, CompareInfoEventArgs e) 
        {
            ((CompareFormThread)_formThread).EndCompare (e.Info, "");
        }
        #endregion Event handlers 
    }
}